﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Entities;
using Bussiness;

namespace ShoppingCartWEB
{
    public partial class ProductDetail : System.Web.UI.Page
    {
        private ProductManager pm  = new ProductManager();
        private CategoryManager cm = new CategoryManager();
        private SupplierManager sm = new SupplierManager();
        public Product pr = new Product();
        public string sCategory = "";
        public string sSupplier = "";
        public string isStored = "Unavailable";
        protected void Page_Load(object sender, EventArgs e)
        {
            int pid = Int32.Parse(Request.QueryString["pid"]);
            pr = pm.GetProductById(pid);
          
            foreach (Category ca in cm.AllCategory())
            {
                if (ca.CategoryID == pr.CategoryID)
                {
                    sCategory = ca.CategoryName;
                }
            }
         
            foreach (Supplier sp in sm.AllSupplier())
            {
                if (sp.SupplierID == pr.SupplierID)
                {
                    sSupplier = sp.CompanyName;
                }
            }

            if (pr.Quantity > 0)
            {
                isStored = "Available";
            }
        }
    }
}